package com.xw.bo.ks.controller.no;

import com.alibaba.fastjson.JSONObject;
import com.xw.bo.ks.kafka.KafkaProducer;
import com.xw.bo.ks.service.HtpRequestService;
import com.xw.bo.ks.service.TokenService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author： XW -> ~
 * @create： 2024/3/28 19:01
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private KafkaProducer kafkaProducer;

    @Autowired
    private HtpRequestService htpRequestService;

    @Autowired
    private TokenService tokenService;

    @GetMapping(value = "/kafka")
    public String kafkaTest(String msg,String topic) {

        log.info("request path: {}, param: {}", "/api/demo/kafka/send", msg);
        kafkaProducer.sendMessage(topic,msg);
        return "ok";
    }

    @GetMapping(value = "/request")
    public String request(String msg,String topic) {
        htpRequestService.htpAll();
        return "ok";
    }

    @GetMapping(value = "/setUserId")
    public String setUserId(Integer uid) {
        tokenService.refreshToken(uid);
        return "ok";
    }




}
